<!DOCTYPE html>
<head>
</head>
<body>
<div id="result">RESULT</div>
<script>

var resultDiv = document.getElementById('result');

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

var count = 0;

var observer = new MutationObserver(function(r) {
    count += r.length;
});

var div = document.createElement('div');
observer.observe(div, { attributes: true });

function mutate() {
      div.setAttribute('count', count);
}

var counts = [];
function check() {
    counts.push(count);
}

function finish() {
    setTimeout(function() {
        check();

        var result = counts[0] == 0 &&
                     counts[1] == 0 &&
                     counts[2] == 0 &&
                     counts[3] == 1 ? 'PASSED' : 'FAILED';

        document.documentElement.appendChild(document.createElement('body'));
        document.body.innerHTML = result;
        if (window.testRunner) {
            testRunner.notifyDone();
        }
    }, 0);
}

finish();
</script>
<iframe onload="mutate(); check(); document.write('<script>check();</script>'); document.close(); check(); finish();">
</body>
